;----------------------------------------
; Assembler code generated file
; Authors:
;     Strokina N.V., gr. 4395
;     Usenko   A.V., gr. 4351
;
;     SPbGETU 'LETI', 2009
;
;----------------------------------------

.MODEL SMALL

EXTRN	 _print_i:    PROC
EXTRN	 _print_s:    PROC
EXTRN	 _scan_i:     PROC
EXTRN	 _add_matrix: PROC
EXTRN	 _sub_matrix: PROC
EXTRN	 _mul_matrix: PROC

.DATA

;--- Identifiers ---
	e0	DW	1
	e1	DW	2
	e2	DW	3
	e3	DW	4
	e4	DW	?
	i5	DW	4
	i6	DW	2
	i7	DW	2
	i8	DW	4
	m9	DW	  1,  1
		DW	  2,  2
		DW	  3,  3
		DW	  4,  4
	m10	DW	8 dup (0)
	i11	DW	?
	i12	DW	?
	i13	DW	?
	i14	DW	?
	i15	DW	4
	i16	DW	4
	m17	DW	16 dup (0)

;--- Strings ---
	s0	DB	0DH,0AH, 0
	s1	DB	"Hello", 0
	s2	DB	"First matrix[", 0
	s3	DB	",", 0
	s4	DB	"]:", 0
	s5	DB	" ", 0
	s6	DB	"Enter matrix2[", 0
	s7	DB	",", 0
	s8	DB	"]:", 0
	s9	DB	"Multiply...", 0
	s10	DB	"Result matrix3[", 0
	s11	DB	",", 0
	s12	DB	"]:", 0
	s13	DB	" ", 0
	s14	DB	"Press any key to exit...", 0

.CODE
PUBLIC _main
_main PROC far

	mov  AX, 4
	mov  i15, AX
	mov  AX, 4
	mov  i16, AX
	lea  AX, s1
	push AX
	call _print_s
	add  SP, 2
	lea  AX, s0
	push AX
	call _print_s
	add  SP, 2
	lea  AX, s2
	push AX
	call _print_s
	add  SP, 2
	mov  AX, 4
	push AX
	call _print_i
	add  SP, 2
	lea  AX, s3
	push AX
	call _print_s
	add  SP, 2
	mov  AX, 2
	push AX
	call _print_i
	add  SP, 2
	lea  AX, s4
	push AX
	call _print_s
	add  SP, 2
	lea  AX, s0
	push AX
	call _print_s
	add  SP, 2
	mov  AX, i13
	push AX
	mov  AX, 0
	mov  i13, AX
	mov  AX, i14
	push AX
	mov  AX, 0
	mov  i14, AX
@DoWhileBegin1:
@DoWhileBegin3:
	mov  AX, i13
	push AX
	mov  AX, i14
	push AX
	pop  BX
	pop  AX
	mov  DX, 2
	imul DX
	add  AX, BX
	mov  DX, 2
	imul DX
	mov  SI, AX
	mov  AX, m9[SI]
	push AX
	call _print_i
	add  SP, 2
	lea  AX, s5
	push AX
	call _print_s
	add  SP, 2
	mov  AX, i14
	inc  AX
	mov  i14, AX
	mov  AX, i14
	push AX
	mov  AX, i6
	mov  BX, AX
	pop  AX
	cmp  AX, BX
	jl   @True12
	mov  AX, 00
	jmp  @End13
@True12:
	mov  AX, 01
@End13:
	cmp  AX, 00
	je   @DoWhileEnd2
	jmp  @DoWhileBegin3
@DoWhileEnd2:
	lea  AX, s0
	push AX
	call _print_s
	add  SP, 2
	mov  AX, i13
	inc  AX
	mov  i13, AX
	mov  AX, i13
	push AX
	mov  AX, i5
	mov  BX, AX
	pop  AX
	cmp  AX, BX
	jl   @True14
	mov  AX, 00
	jmp  @End15
@True14:
	mov  AX, 01
@End15:
	cmp  AX, 00
	je   @DoWhileEnd0
	jmp  @DoWhileBegin1
@DoWhileEnd0:
	lea  AX, s6
	push AX
	call _print_s
	add  SP, 2
	mov  AX, 2
	push AX
	call _print_i
	add  SP, 2
	lea  AX, s7
	push AX
	call _print_s
	add  SP, 2
	mov  AX, 4
	push AX
	call _print_i
	add  SP, 2
	lea  AX, s8
	push AX
	call _print_s
	add  SP, 2
	lea  AX, s0
	push AX
	call _print_s
	add  SP, 2
	mov  AX, i13
	push AX
	mov  AX, 0
	mov  i13, AX
	mov  AX, i14
	push AX
	mov  AX, 0
	mov  i14, AX
@DoWhileBegin5:
@DoWhileBegin7:
	mov  AX, i13
	push AX
	mov  AX, i14
	push AX
	pop  BX
	pop  AX
	mov  DX, 4
	imul DX
	add  AX, BX
	mov  DX, 2
	imul DX
	mov  BX, AX
	lea  AX, m10
	add  AX, BX
	push AX
	call _scan_i
	add  SP, 2
	mov  AX, i14
	inc  AX
	mov  i14, AX
	mov  AX, i14
	push AX
	mov  AX, i8
	mov  BX, AX
	pop  AX
	cmp  AX, BX
	jl   @True16
	mov  AX, 00
	jmp  @End17
@True16:
	mov  AX, 01
@End17:
	cmp  AX, 00
	je   @DoWhileEnd6
	jmp  @DoWhileBegin7
@DoWhileEnd6:
	mov  AX, i13
	inc  AX
	mov  i13, AX
	mov  AX, i13
	push AX
	mov  AX, i7
	mov  BX, AX
	pop  AX
	cmp  AX, BX
	jl   @True18
	mov  AX, 00
	jmp  @End19
@True18:
	mov  AX, 01
@End19:
	cmp  AX, 00
	je   @DoWhileEnd4
	jmp  @DoWhileBegin5
@DoWhileEnd4:
	push AX
	push AX
	add  SP, 2
	mov  AX, 4
	push AX
	mov  AX, 4
	push AX
	lea  AX, m17
	push AX
	lea  AX, m9
	push AX
	lea  AX, m9
	push AX
	call _sub_matrix
	add  SP, 10
	lea  AX, s9
	push AX
	call _print_s
	add  SP, 2
	lea  AX, s0
	push AX
	call _print_s
	add  SP, 2
	lea  AX, s10
	push AX
	call _print_s
	add  SP, 2
	mov  AX, 4
	push AX
	call _print_i
	add  SP, 2
	lea  AX, s11
	push AX
	call _print_s
	add  SP, 2
	mov  AX, 2
	push AX
	call _print_i
	add  SP, 2
	lea  AX, s12
	push AX
	call _print_s
	add  SP, 2
	lea  AX, s0
	push AX
	call _print_s
	add  SP, 2
	mov  AX, i13
	push AX
	mov  AX, 0
	mov  i13, AX
	mov  AX, i14
	push AX
	mov  AX, 0
	mov  i14, AX
@DoWhileBegin9:
@DoWhileBegin11:
	mov  AX, i13
	push AX
	mov  AX, i14
	push AX
	pop  BX
	pop  AX
	mov  DX, 2
	imul DX
	add  AX, BX
	mov  DX, 2
	imul DX
	mov  SI, AX
	mov  AX, m9[SI]
	push AX
	call _print_i
	add  SP, 2
	lea  AX, s13
	push AX
	call _print_s
	add  SP, 2
	mov  AX, i14
	inc  AX
	mov  i14, AX
	mov  AX, i14
	push AX
	mov  AX, i16
	mov  BX, AX
	pop  AX
	cmp  AX, BX
	jl   @True20
	mov  AX, 00
	jmp  @End21
@True20:
	mov  AX, 01
@End21:
	cmp  AX, 00
	je   @DoWhileEnd10
	jmp  @DoWhileBegin11
@DoWhileEnd10:
	lea  AX, s0
	push AX
	call _print_s
	add  SP, 2
	mov  AX, i13
	inc  AX
	mov  i13, AX
	mov  AX, i13
	push AX
	mov  AX, i15
	mov  BX, AX
	pop  AX
	cmp  AX, BX
	jl   @True22
	mov  AX, 00
	jmp  @End23
@True22:
	mov  AX, 01
@End23:
	cmp  AX, 00
	je   @DoWhileEnd8
	jmp  @DoWhileBegin9
@DoWhileEnd8:
	lea  AX, s14
	push AX
	call _print_s
	add  SP, 2
	mov  AX, i13
	lea  AX, i13
	push AX
	call _scan_i
	add  SP, 2
	jmp  @return
@return:

	mov  AH, 4CH
	int  21H
_main ENDP
END _main
